package nancal.mp.mvc.ops


import nancal.mp.service.K8sService
import nbcp.base.annotation.Require
import nbcp.base.comm.JsonResult
import nbcp.base.extend.AsString
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@RequestMapping("/ops/k8s/external-service")
@RestController
class K8sExternalServiceController {

    @Autowired
    lateinit var k8sService: K8sService

    @PostMapping("/add")
    fun apply(
        targetEnv: String,
        @Require namespace: String,
        @Require name: String,
        @Require sourceNamespace: String,
        @Require  sourceName: String,
    ): JsonResult {
        k8sService.createExternalService(targetEnv, namespace, name, sourceNamespace, sourceName.AsString(name));
        return JsonResult();
    }

}